package com.wafersystems.springbootdemo.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 异步任务@Async注解的方法，不能跟调用者在同一个类中
 * @author tandk
 * @date 2018/12/5 17:45
 */
@Slf4j
@Service
public class DemoAsyncTask {
    /**
     * 异步任务
     */
    @Async("demoAsync")
    public void asyncTask(){
        log.info("异步任务执行开始。。。。");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("异步任务执行结束。。。。");
    }
}
